package kepu_res

import (
	"github.com/jinzhu/gorm"
)

type ResDetail struct {
	Uuid    string `json:"uuid"`
	Id      int    `json:"id"`
	Summary string `json:"summary"`
	Content string `json:"Content"`
}

func (m *ResDetail) TableName() string {
	return "resource_detail"
}

func GetDetail(uuids []string) (detail map[string]map[string]string, err error) {
	detail = make(map[string]map[string]string)
	var resDetail []ResDetail
	err = db.Table("resource_detail").Where("uuid in (?) ", uuids).Find(&resDetail).Error

	if err != nil && err != gorm.ErrRecordNotFound {
		return detail, err
	}
	for _, de := range resDetail {
		detail[de.Uuid] = make(map[string]string)
		detail[de.Uuid]["summary"] = de.Summary
		detail[de.Uuid]["content"] = de.Content
	}
	return detail, err
}
